﻿using System;
using System.Text;
using HslCommunication.Core;

namespace HslCommunication.Robot.FANUC
{
	/// <summary>
	/// Fanuc机器人的任务类
	/// </summary>
	// Token: 0x02000038 RID: 56
	public class FanucTask
	{
		/// <summary>
		/// ProgramName
		/// </summary>
		// Token: 0x170000E3 RID: 227
		// (get) Token: 0x0600048C RID: 1164 RVA: 0x00012D10 File Offset: 0x00010F10
		// (set) Token: 0x0600048D RID: 1165 RVA: 0x00012D18 File Offset: 0x00010F18
		public string ProgramName { get; set; }

		/// <summary>
		/// LineNumber
		/// </summary>
		// Token: 0x170000E4 RID: 228
		// (get) Token: 0x0600048E RID: 1166 RVA: 0x00012D21 File Offset: 0x00010F21
		// (set) Token: 0x0600048F RID: 1167 RVA: 0x00012D29 File Offset: 0x00010F29
		public short LineNumber { get; set; }

		/// <summary>
		/// State
		/// </summary>
		// Token: 0x170000E5 RID: 229
		// (get) Token: 0x06000490 RID: 1168 RVA: 0x00012D32 File Offset: 0x00010F32
		// (set) Token: 0x06000491 RID: 1169 RVA: 0x00012D3A File Offset: 0x00010F3A
		public short State { get; set; }

		/// <summary>
		/// ParentProgramName
		/// </summary>
		// Token: 0x170000E6 RID: 230
		// (get) Token: 0x06000492 RID: 1170 RVA: 0x00012D43 File Offset: 0x00010F43
		// (set) Token: 0x06000493 RID: 1171 RVA: 0x00012D4B File Offset: 0x00010F4B
		public string ParentProgramName { get; set; }

		/// <summary>
		/// 从原始的数据对象加载数据信息
		/// </summary>
		/// <param name="byteTransform">字节变换</param>
		/// <param name="content">原始的字节数据</param>
		/// <param name="index">索引信息</param>
		/// <param name="encoding">编码</param>
		// Token: 0x06000494 RID: 1172 RVA: 0x00012D54 File Offset: 0x00010F54
		public void LoadByContent(IByteTransform byteTransform, byte[] content, int index, Encoding encoding)
		{
			this.ProgramName = encoding.GetString(content, index, 16).Trim(new char[1]);
			this.LineNumber = BitConverter.ToInt16(content, index + 16);
			this.State = BitConverter.ToInt16(content, index + 18);
			this.ParentProgramName = encoding.GetString(content, index + 20, 16).Trim(new char[1]);
		}

		/// <inheritdoc />
		// Token: 0x06000495 RID: 1173 RVA: 0x00012DC1 File Offset: 0x00010FC1
		public override string ToString()
		{
			return string.Format("ProgramName[{0}] LineNumber[{1}] State[{2}] ParentProgramName[{3}]", new object[]
			{
				this.ProgramName,
				this.LineNumber,
				this.State,
				this.ParentProgramName
			});
		}

		/// <summary>
		/// 从原始的数据信息初始化一个任务对象
		/// </summary>
		/// <param name="byteTransform">字节变换</param>
		/// <param name="content">原始的字节数据</param>
		/// <param name="index">索引信息</param>
		/// <param name="encoding">编码</param>
		/// <returns>任务对象</returns>
		// Token: 0x06000496 RID: 1174 RVA: 0x00012E04 File Offset: 0x00011004
		public static FanucTask PraseFrom(IByteTransform byteTransform, byte[] content, int index, Encoding encoding)
		{
			FanucTask fanucTask = new FanucTask();
			fanucTask.LoadByContent(byteTransform, content, index, encoding);
			return fanucTask;
		}
	}
}
